package com.easy;

/**
 * Created by Lxk on 2020/2/18.
 */
public class Solution326 {

    public boolean isPowerOfThree(int n) {
        while (n != 0) {
            if (n == 1) {
                return true;
            }
            if (n % 3 != 0) {
                return false;
            }
            n /= 3;
        }
        return true;
    }

    public static void main(String[] args) {
        Solution326 solution326 = new Solution326();
        System.out.println(solution326.isPowerOfThree(2));
    }

}
